package com.gap.donot;

import java.io.File;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.view.Display;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

public class EnterActivity extends Activity {

	static Context is;
	private int screenX;
	private int screenY;
	float imgX,imgY,textX,textY;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_enter);
		is = this;
		ImageView imageView = (ImageView) findViewById(R.id.enterImage);
		TextView textView = (TextView)findViewById(R.id.enterText);
		imgX = imageView.getLeft();
		imgY = imageView.getTop();
		textX = textView.getLeft();
		textY = textView.getTop();
		TranslateAnimation translateAnimation = new TranslateAnimation((float) (screenX/2.0),
				imgX, 1000f, imgY);
		translateAnimation.setDuration(2000);

		imageView.setAnimation(translateAnimation);
		TranslateAnimation translate = new TranslateAnimation((float) (screenX/2.0),
				textX, -200f, textY);
		translate.setDuration(2000);

		textView.setAnimation(translate);

		Handler handler = new Handler();
		handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				check();
			}
		}, 3000);
	}
	public void check() {
		File file = new File(Environment.getExternalStorageDirectory()+"/NumberWar/save.dat");
		if(file.exists())
		{
			Intent intent = new Intent();
			intent.setClass(EnterActivity.this, SelectActivity.class);
			startActivity(intent);
			finish();
		}else {
			file.mkdirs();
			Intent intent = new Intent();
			intent.setClass(EnterActivity.this, LeadActivity.class);
			startActivity(intent);
			finish();
		}
	}

	public void getScreenSize() {
		Display display = getWindowManager().getDefaultDisplay();
		screenX = display.getWidth();
		screenY = display.getHeight();
	}

}
